package liumengbaio.lolzhangyoubao.Activity.Activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ImageView;

import java.util.List;

import liumengbaio.lolzhangyoubao.Activity.Adapter.MoreSummonerAdapter;
import liumengbaio.lolzhangyoubao.Activity.InFo.SummonerSkillsInfo;
import liumengbaio.lolzhangyoubao.Activity.utils.SummonerSkillsUtils;
import liumengbaio.lolzhangyoubao.R;

/**
 * Created by lanouhn on 16/9/1.
 */
public class MoreSkillsActivity extends AppCompatActivity {

    private List<SummonerSkillsInfo> mList;
    private MoreSummonerAdapter mMoreSummonerAdapter;
    private GridView mGridView;
    private ImageView back;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.more_skill);
        initView();
        initData();
        initEvent();
    }

    private void initView() {
        mGridView = (GridView) findViewById(R.id.more_gridView);
        back= (ImageView) findViewById(R.id.more_skill_back);
    }

    private void initEvent() {
        mGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Intent intent = new Intent(MoreSkillsActivity.this, MoreSkillDetails.class);
                intent.putExtra("name", mList.get(position).getName());
                intent.putExtra("id", mList.get(position).getId());
                intent.putExtra("level", mList.get(position).getLevel());
                intent.putExtra("desc", mList.get(position).getDesc());
                intent.putExtra("pic_url", mList.get(position).getPic_url());
                intent.putExtra("cold", mList.get(position).getCode());
                startActivity(intent);
            }
        });
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    private void initData() {
        mList = SummonerSkillsUtils.getSummonerSkillsInfo(this);
        mMoreSummonerAdapter = new MoreSummonerAdapter(mList, this);
        mGridView.setAdapter(mMoreSummonerAdapter);

    }
}
